﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace ECONTACT.DataLayer
{
    public class MonHocData
    {
        DataService m_MonHocData = new DataService();

        public DataTable LayDsMonHoc()
        {
            SqlCommand cmd = new SqlCommand("SELECT * FROM MONHOC");
            m_MonHocData.Load(cmd);
            return m_MonHocData;
        }

        public void LuuMonHoc(String TenMH, String HeSo)
        {
            SqlCommand cmd = new SqlCommand("sp_ThemMonHoc");

            cmd.Parameters.Add("@TenMH", SqlDbType.NVarChar).Value = TenMH;
            cmd.Parameters.Add("@HeSo", SqlDbType.Int).Value = Convert.ToInt32(HeSo);

            m_MonHocData.LoadProc(cmd);
        }

        public void UpdateMonHoc(String MaMH, String TenMH, String HeSo)
        {
            SqlCommand cmd = new SqlCommand("sp_CapNhatMonHoc");

            cmd.Parameters.Add("@MaMH", SqlDbType.NVarChar).Value = MaMH;
            cmd.Parameters.Add("@TenMH", SqlDbType.NVarChar).Value = TenMH;
            cmd.Parameters.Add("@HeSo", SqlDbType.Int).Value = Convert.ToInt32(HeSo);

            m_MonHocData.LoadProc(cmd);
        }

        public void DeleteMonHoc(String MaMH)
        {
            SqlCommand cmd = new SqlCommand("sp_XoaMonHoc");
            cmd.Parameters.Add("@MaMH", SqlDbType.Int).Value = Convert.ToInt32(MaMH);

            m_MonHocData.LoadProc(cmd);
        }
    }
}
